import axios from 'axios'
import qs from 'qs'
//实例化一个axios
var api = axios.create({
    baseURL: '/videosys/public/index.php/api/index/',
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    timeout: 15000,
    //序列化方法
    transformRequest: function (data) {
        return qs.stringify(data, {arrayFormat: 'brackets'}) //用qs格式化数据为表单类型
    }
})
export default {
    /*上传视频*/
    uploadVideo(data = {}) {
        return new axios.post('uploadvideo', data, {
            baseURL: '/videosys/public/index.php/api/index/',
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    },  /*上传视频*/
   edituser(data = {}) {
        return new axios.post('edituserinfo', data, {
            baseURL: '/videosys/public/api/index/',
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    },
    /*获取视频列表*/
    getVideoList(data = {}) {
        return new api.post('getvideolist', data);
    },
    /*获取喜欢的视频列表*/
    getLikeVideoList(data = {}) {
        return new api.post('getlikevideolist', data);
    },
    /*注册*/
    register(data = {}) {
        return new api.post('register', data);
    },
    /*登陆*/
    login(data = {}) {
        return new api.post('login', data);
    },
    /*获取用户信息*/
    getUserInfo(data = {}) {
        return new api.post('getuserinfo', data);
    },
    /*喜欢*/
    like(data = {}) {
        return new api.post('likevideo', data);
    }, /*取消喜欢*/
    unlike(data = {}) {
        return new api.post('unlikevideo', data);
    }, /*赞*/
    zan(data = {}) {
        return new api.post('starvideo', data);
    }, /*取消赞*/
    unzan(data = {}) {
        return new api.post('unstarvideo', data);
    },
    /*获取视频*/
    getvideo(data = {}) {
        return new api.post('getvideo', data);
    },
    /*删除视频*/
    delvideo(data = {}) {
        return new api.post('delvideo', data);
    },
    /*获取评论*/
    getVideoMes(data = {}) {
        return new api.post('getvideomessage', data);
    },
    /*发表*/
    addVideoMes(data = {}) {
        return new api.post('addmessage', data);
    },
    /*删除评论*/
    delVideoMes(data = {}) {
        return new api.post('delmessage', data);
    },

}
